package com.fcfspace.loongfei;

import com.fcfspace.loongfei.dao.DaoHelper;
import com.fcfspace.loongfei.dao.bean.PageParameter;
import com.fcfspace.loongfei.utils.CollectionEdit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/testTwo")
public class DaoTestController {
    @Autowired
    private DaoHelper daoHelper;
    @Autowired
    private DaoHelper druidDaoHelper;

    @RequestMapping("/dbData")
    public String geiDBData(){
        PageParameter pageParameter = new PageParameter();
        pageParameter.setPageSize(2);

        Map<String,Object> parmater = new HashMap<String,Object>();
        parmater.put("pageParameter",pageParameter);

        List<Map<String,Object>> aList = daoHelper.queryForPageList("caiPiao.selectMySQLTest", parmater);
        System.out.println("-->" + pageParameter.getTotalCount());
        System.out.println(aList);
        String result = CollectionEdit.listToString(aList);
        return result;
    }

    @RequestMapping("/dbDruidData")
    public String geiDruidDBData(){
        PageParameter pageParameter = new PageParameter();
        pageParameter.setPageSize(2);

        Map<String,Object> parmater = new HashMap<String,Object>();
        parmater.put("pageParameter",pageParameter);

        List<Map<String,Object>> aList = druidDaoHelper.queryForPageList("caiPiao.selectMySQLTest", parmater);
        System.out.println("-->" + pageParameter.getTotalCount());
        System.out.println(aList);
        String result = CollectionEdit.listToString(aList);
        return result;
    }

    public DaoHelper getDaoHelper() {
        return daoHelper;
    }

    public void setDaoHelper(DaoHelper daoHelper) {
        this.daoHelper = daoHelper;
    }

    public DaoHelper getDruidDaoHelper() {
        return druidDaoHelper;
    }

    public void setDruidDaoHelper(DaoHelper druidDaoHelper) {
        this.druidDaoHelper = druidDaoHelper;
    }
}
